package com.example.XuLieHua;

import java.io.*;

public class ObjectOutputStreams {
    public static void main(String[] args) {
        MyClass myClass = new MyClass();
        myClass.name = "Reyan Ali";
        myClass.address = "Phokka Kuan, Ambehta Peer";
        myClass.SSN = 11122333;
        myClass.number = 101;
        try {
            // C:/Users/47054/Desktop/hello/bb.txt
            // 打开序列化保存的文件
            FileOutputStream fileout = new FileOutputStream("C:/Users/47054/Desktop/hello/cc.txt");
            // new序列化接口
            ObjectOutputStream objout = new ObjectOutputStream(fileout);
            objout.writeObject(myClass);
            objout.close();
            fileout.close();
            System.out.println("Object written successfully");
        } catch (IOException e){
            e.printStackTrace();
        }
    }
}
